#include "config.h"

#include "ms2sim.h"

#ifdef MSM_DEBUG

const char *
dbg_session_state(session_state_t state)
{
	switch (state) {
	case STATE_IDLE:
		return "<idle>";
	case STATE_DISKIO:
		return "<diskio>";
	case STATE_LOADED:
		return "<loaded>";
	case STATE_DONE:
		return "<done>";
	default:
		return "<unknown>";
	}
}

const char *
dbg_timestep(ecm_uint64 ts)
{
	static char	buf[64];

	ecm_snprintf(buf, 64, "%u.%u", ts / USEC_MAX, ts % USEC_MAX);
	return buf;
}

const char *
dbg_session(session_t *session)
{
	static char	buf[256];

	if (session == NULL)
		return "null";
	ecm_snprintf(buf, 256, "id:%u %s %s m:%u b:%u cb:%u r:%u %u",
		     session->sid,
		     dbg_session_state(session->state),
		     dbg_timestep(session->ts),
		     session->media->mid,
		     session->bytes_buffered,
		     session->bytes_buffered_client,
		     session->usec_round,
		     session->bytes_round);
	return buf;
}

#endif
